package com.greenhouse.business.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.greenhouse.business.domain.BizCameraManage;
import com.greenhouse.business.service.IBizCameraManageService;
import com.greenhouse.common.annotation.Log;
import com.greenhouse.common.core.controller.BaseController;
import com.greenhouse.common.core.domain.AjaxResult;
import com.greenhouse.common.core.page.TableDataInfo;
import com.greenhouse.common.enums.BusinessType;
import com.greenhouse.common.utils.poi.ExcelUtil;

/**
 * 监测设备管理Controller
 * 
 * @author greenhouse
 * @date 2021-05-13
 */
@RestController
@RequestMapping("/insect/manage")
public class BizCameraManageController extends BaseController {
	@Autowired
	private IBizCameraManageService bizCameraManageService;

	/**
	 * 查询监测设备管理列表
	 */
	@PreAuthorize("@ss.hasPermi('insect:manage:list')")
	@GetMapping("/list")
	public TableDataInfo list(BizCameraManage bizCameraManage) {
		startPage();
		List<BizCameraManage> list = bizCameraManageService.selectBizCameraManageList(bizCameraManage);
		return getDataTable(list);
	}

	/**
	 * 导出监测设备管理列表
	 */
	@PreAuthorize("@ss.hasPermi('insect:manage:export')")
	@Log(title = "监测设备管理", businessType = BusinessType.EXPORT)
	@GetMapping("/export")
	public AjaxResult export(BizCameraManage bizCameraManage) {
		List<BizCameraManage> list = bizCameraManageService.selectBizCameraManageList(bizCameraManage);
		ExcelUtil<BizCameraManage> util = new ExcelUtil<BizCameraManage>(BizCameraManage.class);
		return util.exportExcel(list, "manage");
	}

	/**
	 * 获取监测设备管理详细信息
	 */
	@PreAuthorize("@ss.hasPermi('insect:manage:query')")
	@GetMapping(value = "/{id}")
	public AjaxResult getInfo(@PathVariable("id") Long id) {
		return AjaxResult.success(bizCameraManageService.selectBizCameraManageById(id));
	}

	/**
	 * 新增监测设备管理
	 */
	@PreAuthorize("@ss.hasPermi('insect:manage:add')")
	@Log(title = "监测设备管理", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody BizCameraManage bizCameraManage) {
		return toAjax(bizCameraManageService.insertBizCameraManage(bizCameraManage));
	}

	/**
	 * 修改监测设备管理
	 */
	@PreAuthorize("@ss.hasPermi('insect:manage:edit')")
	@Log(title = "监测设备管理", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody BizCameraManage bizCameraManage) {
		return toAjax(bizCameraManageService.updateBizCameraManage(bizCameraManage));
	}

	/**
	 * 删除监测设备管理
	 */
	@PreAuthorize("@ss.hasPermi('insect:manage:remove')")
	@Log(title = "监测设备管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
	public AjaxResult remove(@PathVariable Long[] ids) {
		return toAjax(bizCameraManageService.deleteBizCameraManageByIds(ids));
	}
}
